// components/music/index.js
import {classicBeh} from "../classic-beh"

const mMgr = wx.getBackgroundAudioManager()

Component({
  /**
   * 组件的属性列表
   */
  behaviors: [classicBeh],
  properties: {
    src: String
  },

  /**
   * 组件的初始数据
   */
  data: {
    pauseSrc: 'images/player@waitting.png',
    playSrc: 'images/player@playing.png',
    playing:false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onPlay:function(event){
      if (!this.data.playing){
        this.setData({
          playing: true
        })
        mMgr.src = this.properties.src
      }else{
        this.setData({
          playing: false
        })
        mMgr.pause()
      }
      
    }
  },

  detached: function(){
    mMgr.stop()
  }
})
